package com.jeff.android.lab.jetpack.startup;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.startup.Initializer;

import com.alibaba.android.arouter.launcher.ARouter;
import com.jeff.android.lab.AppApplication;
import com.jeff.android.lab.BuildConfig;

import java.util.Collections;
import java.util.List;

/**
 * 手动初始化，因为ContentProvider 执行 onCreate 方法时，Application 还未初始化
 *
 * @author: dingfeng
 * @date: 2020-10-30
 * @since: 1.0.0
 **/
public class ARouterInitializer implements Initializer<Object> {
    @NonNull
    @Override
    public Object create(@NonNull Context context) {
        if (BuildConfig.DEBUG) {
            ARouter.openDebug();
            ARouter.openLog();
        }
        ARouter.init(AppApplication.getInstance());
        return null;
    }

    @NonNull
    @Override
    public List<Class<? extends Initializer<?>>> dependencies() {
        return Collections.emptyList();
    }
}
